﻿<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>百度地图API</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=XgytY5awff9jZFzhmwkHh3ZYXM560rf5"></script>
<style type="text/css">
    body, html {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
</head>
<body>
<div id="allmap" style="width: 400px;height: 300px;"></div>
<div id="r-result">
    经度: <input id="longitude" type="text" style="width:100px; margin-right:10px;" />
    纬度: <input id="latitude" type="text" style="width:100px; margin-right:10px;" />
    <input type="button" value="查询" onclick="theLocation()" />
</div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能


    var map = new BMap.Map("allmap");
    map.centerAndZoom(new BMap.Point(116.331398,39.897445),19);
    map.enableScrollWheelZoom(true);

    // 用经纬度设置地图中心点
    function theLocation() {
        if (document.getElementById("longitude").value != "" && document.getElementById("latitude").value != "") {
            map.clearOverlays();
            var new_point = new BMap.Point(document.getElementById("longitude").value, document.getElementById("latitude").value);
            var marker = new BMap.Marker(new_point);  // 创建标注
            map.addOverlay(marker);              // 将标注添加到地图中
            map.panTo(new_point);
            Radio2_onclick();
        }
    }
    ;
    function getLon()
    {
        return window.external.GetLon();
    }
    function getLat()
    {
        return window.external.GetLat();
    }
    function Radio2_onclick() {
        //js调用winform方法
        //alert(document.getElementById("longitude").value+'s'+document.getElementById("latitude").value);
        window.external.GetLatLon(document.getElementById("longitude").value, document.getElementById("latitude").value);
    }
</script>